<template>
	<mescroll-uni ref="mescrollRef" :up="upOption" :down="downOption" @init="mescrollInit" @up="upCallback" @down="downCallback" :fixed="false">
		<view class="pro">
			<view class="list"><cmt-reply v-for="(item, indexs) in commentList" :key="indexs" :info="item"></cmt-reply></view>
		</view>
	</mescroll-uni>
</template>

<script>
import profilterbar from '@/components/profilterbar';
import cmtReply from '@/components/cmt-reply';
import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js';
export default {
	name: 'pros',
	mixins: [MescrollMixin],
	data() {
		return {
			commentList: [],
			downOption: {
				auto: false // 不自动加载
			},
			upOption: {
				auto: false // 不自动加载
			},
			filter: {}
		};
	},

	components: { cmtReply },
	methods: {
		init(shopId, cateId) {
			this.shopId = shopId;
			this.mescroll.resetUpScroll();
		},
		downCallback() {
			this.mescroll.resetUpScroll();
		},
		upCallback() {
			if (this.shopId) {
				this.getCommentList();
			} else {
				this.mescroll.endSuccess(0, false);
			}
		},
		changeFilrer(filter) {
			this.mescroll.resetUpScroll();
		},
		getCommentList(type) {
			let pageNum = this.mescroll.num; // 页码, 默认从1开始
			let pageSize = this.mescroll.size;
			let param = {
				page: pageNum,
				limit: pageSize
			};

			this.$postAction(this.$api.getProductEvaluate + this.shopId + '/1', param, {
				custom: {
					ShowLoading: false
				}
			}).then(da => {
				if (da.code == 0 && da.data && da.data.length > 0) {
					let curPageData = da.data;
					this.mescroll.endBySize(curPageData.length, da.count);
					if (this.mescroll.num == 1) this.commentList = []; //如果是第一页需手动制空列表
					this.commentList = this.commentList.concat(curPageData); //追加新数据
				} else {
					if (this.mescroll.num == 1) this.commentList = [];
					this.mescroll.endSuccess(0, false);
				}
			});
		}
	}
};
</script>

<style>
.pro {
	position: relative;
	z-index: 99;
	background: #fff;
	padding: 24upx 28upx;
}
</style>
